package org.example.demo1;

import lombok.extern.slf4j.Slf4j;

/**
 * @author Gong.Yang
 * 线程状态变化演示
 */
@Slf4j
public class DemoThreadStatus {
    public static void main(String[] args) throws InterruptedException {
        Runnable task = () -> showStatus(Thread.currentThread());
        Thread thread = new Thread(task);
        showStatus(thread);  //当前线程状态->NEW
        thread.start();     //当前线程状态->RUNNABLE
        thread.join();
        showStatus(thread); //当前线程状态->TERMINATED
    }

    static void showStatus(Thread thread) {
        log.info("当前线程状态->{}", thread.getState());
    }
}
